package com.anorak.betsy.util;

import com.anorak.betsy.entity.Music;
import com.anorak.betsy.entity.Verify;

/**
 * @author anorak
 */
public class DownloadsUtil {


    public static void downloads(Music music) throws Exception {
        Verify verify = HiFiNiUtil.getCaptcha();
        if (verify != null) {
            Integer move = VerifyUtil.verifyDecrypt(verify);
            if (move != 0) {
                boolean flag = HiFiNiUtil.checkCaptcha(verify, move);
                if (flag) {
                    boolean login = HiFiNiUtil.loginAccount(verify);
                    if ( login ){
                        System.out.println("HiFiNi账号登录成功!");
                        HiFiNiUtil.signAccount(verify);
                        HiFiNiUtil.searchMusic(verify, music);
                        HiFiNiUtil.downloadMusic(music);
                        HiFiNiUtil.logMusic(music);
                    }else {
                        System.out.println("HiFiNi账号登录失败!");
                    }
                }else {
                    System.out.println("HiFiNi验证码校验失败!");
                }
            }else {
                System.out.println("HiFiNi验证码破解失败!");
            }
        }else {
            System.out.println("获取HiFiNi验证码失败!");
        }
        Thread.sleep(1000);
    }

}
